This is a very simple showcase of my first personal theme. It is heavily influenced and based on this template by holtzy.

1 A display of document components.


Some text.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Massa eget egestas purus viverra accumsan. Morbi tincidunt augue interdum velit euismod in pellentesque massa placerat. Nec ullamcorper sit amet risus nullam eget felis. Sed viverra ipsum nunc aliquet bibendum enim facilisis gravida. Egestas sed tempus urna et pharetra pharetra massa massa. Risus sed vulputate odio ut. Tincidunt dui ut ornare lectus sit amet est placerat in. Amet commodo nulla facilisi nullam vehicula ipsum. Purus in mollis nunc sed id semper risus in. Vulputate eu scelerisque felis imperdiet proin fermentum leo vel. Tortor at auctor urna nunc id. Felis bibendum ut tristique et egestas quis. Ac auctor augue mauris augue neque gravida in fermentum.

Condimentum vitae sapien pellentesque habitant morbi. Sit amet aliquam id diam maecenas ultricies mi eget. Consequat ac felis donec et odio. Egestas maecenas pharetra convallis posuere morbi. Orci nulla pellentesque dignissim enim sit amet. Arcu vitae elementum curabitur vitae nunc sed velit dignissim. Arcu bibendum at varius vel pharetra vel turpis nunc eget. Sed felis eget velit aliquet sagittis. Vulputate ut pharetra sit amet aliquam id diam maecenas ultricies. Gravida cum sociis natoque penatibus et magnis dis parturient. Malesuada bibendum arcu vitae elementum curabitur vitae nunc sed. Varius vel pharetra vel turpis nunc. Tellus in hac habitasse platea dictumst. Volutpat blandit aliquam etiam erat velit. Eget duis at tellus at urna condimentum mattis pellentesque. Condimentum id venenatis a condimentum vitae sapien pellentesque habitant morbi. Quis varius quam quisque id diam vel quam elementum. Vel quam elementum pulvinar etiam non.

We can add things like horizontal lines:


1.1 Title 2

1.1.1 Title 3

1.1.1.1 Title 4

1.1.1.1.1 Title 5

Bold text example

Italic text example

1.1.1.2 A list:

  • First item
  • Second item
  • Third item

An example of a footnote.1

We can also display code chunks (in this case a dumb one not evaluated by R):

my_function <- function(x, y) {
  return(x + y)
}

And then we can try some real running code by loading some libraries.

library(tidyverse)
library(rmarkdown)    # You need this library to run this template.
library(crthemes)      # Install with devtools: install_github("drwernicke/crthemes", force=TRUE)

We can have a look at some data:

# Show it:
mtcars %>% head(5)

Inline code: This file has 32 lines and 11 columns. It is ready to be analysed.

2 A table

library(gt)
mtcars %>% 
  rownames_to_column() %>%
  head(5) %>% 
  select(Model = rowname,
         `Miles per gallon` = mpg, 
         `Cylinders` = cyl, 
         `Horsepower`= hp, 
         `Number of gears`= gear) %>%
  gt() %>%
  tab_header(title = "The mtcars dataset") %>%
  tab_spanner(label = "Variable", columns = 2:5) %>%
  tab_source_note(source_note = md("data from `data(mtcars)`")) %>%
  tab_footnote(footnote = "My footnote", locations = cells_title()) %>%
  tab_options(table_body.hlines.width = 0,
              table.font.size = 14,
              table.width = pct(100),
              heading.title.font.weight = "light",
              heading.title.font.size = 18,
              column_labels.font.weight = "bolder",
              table_body.hlines.color = "black",
              data_row.padding = 4)
The mtcars dataset1
Model Variable
Miles per gallon Cylinders Horsepower Number of gears
Mazda RX4 21.0 6 110 4
Mazda RX4 Wag 21.0 6 110 4
Datsun 710 22.8 4 93 4
Hornet 4 Drive 21.4 6 110 3
Hornet Sportabout 18.7 8 175 3
data from data(mtcars)

1 My footnote


This table uses gt() which needs a lot of customizing to look good.

mtcars %>% 
  rownames_to_column() %>%
  head(5) %>% 
  select(Model = rowname,
         `Miles per gallon` = mpg, 
         `Cylinders` = cyl, 
         `Horsepower`= hp, 
         `Number of gears`= gear) %>%
  knitr::kable()
Model Miles per gallon Cylinders Horsepower Number of gears
Mazda RX4 21.0 6 110 4
Mazda RX4 Wag 21.0 6 110 4
Datsun 710 22.8 4 93 4
Hornet 4 Drive 21.4 6 110 3
Hornet Sportabout 18.7 8 175 3

This table uses knitr::kable(), in my opinion it looks better out of the box. It doesn´t support the nice subheadings though.

3 A few figures


Note that the figures are centered. You can change the size of the plot with fig.width and fig.height

3.1 horsepower

First, we will look at the relationship between displacement and horsepower:

mtcars %>%
  ggplot(aes(x = disp, y = hp, color = as.factor(gear))) +
  geom_point() +
  theme_minimal() +
  scale_color_viridis_d(option = 'A')
My figure caption

My figure caption

3.2 Distributions

Lets see what the distributions of horsepower stratified by number of cylinders looks like.

mtcars %>%
  ggplot(aes(x=hp, fill = as.factor(cyl))) +
  geom_density(alpha = .5) +
  theme_minimal() +
  scale_fill_viridis_d(option = 'A')

3.3 Maybe try an interactive plot?

library(plotly)
p <- mtcars %>%
  rownames_to_column() %>%
  ggplot(aes(x = hp, y = mpg)) +
  geom_point() +
  geom_smooth(color = viridis::magma(1, begin = .5), fill = viridis::magma(1, begin = .5), alpha = .2) +
  theme_minimal() 

ggplotly(p)

This graphs shows the relationship between the number of miles per gallon and horsepower in the mtcars dataset.

4 Last paragraph


Read more about this template here.


  1. This is a footnote.↩︎

 




A work by Christian Reitan